import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { ObjCreate } from "../common/ObjCreate";
import { GImageBitmap } from "../../../../com/mui/controls/GImageBitmap";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { ScrollBarDirection } from "../../../../fl/controls/ScrollBarDirection";
import { WrestleEnterCellRenderer } from "./cellRendener/WrestleEnterCellRenderer";
import { PageSelecter } from "../common/pageSelect/PageSelecter";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { DataProvider } from "../../../../fl/data/DataProvider";
type int = number;
//class WrestleEnterWindow
    
    export  class WrestleEnterWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(679, 426);
            titleHeight = 26;
            title = Language.getString(42300);
            this.addEventListener(flash.events.Event.ADDED_TO_STAGE, this.onAddToStage);
            return;
        }

        /* internal  */onAddToStage(arg1: Object /* flash.events.Event */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.WrestleGetRoomList));
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(18, 38, 643, 337, this);
            var loc1=new GImageBitmap("peaceFieldBg.swf", 19, 39);
            this.addChild(loc1);
            this._tileList = new GTileList();
            this._tileList.setSize(590, 246);
            this._tileList.columnWidth = 118;
            this._tileList.rowHeight = 123;
            this._tileList.direction = ScrollBarDirection.VERTICAL;
            this._tileList.horizontalGap = 0;
            this._tileList.verticalGap = 0;
            this._tileList.setStyle("skin", new Object /* flash.display.Bitmap */());
            this._tileList.setStyle("cellRenderer", WrestleEnterCellRenderer);
            this._tileList.x = 30;
            this._tileList.y = 60;
            this.addChild(this._tileList);
            this._pageSelecter = new PageSelecter();
            this._pageSelecter.mode = PageSelecter.CompleteMode;
            this._pageSelecter.addEventListener(flash.events.Event.CHANGE, this.onChange);
            ObjCreate.setObjAttri(this._pageSelecter, 278, 334, -1, -1, this);
            var loc2=new GTextFormat(FontUtil.songtiName, 12, 6350622);
            loc2.leading = 5;
            var loc3=ObjCreate.createTextField("", 18, 380, 440, 40, this, loc2);
            loc3.multiline = true;
            loc3.wordWrap = true;
            loc3.htmlText = Language.getString(42301);
            return;
        }

        public updateList(arg1: Array<any>): void
        {
            this._fields = arg1;
            this._pageSelecter.currentPage = 1;
            this._pageSelecter.maxPage = Math.ceil(this._fields.length / this.PageSize);
            this.updateFieldsByPage();
            return;
        }

        /* internal  */onChange(arg1: Object /* flash.events.Event */): void
        {
            this.updateFieldsByPage();
            return;
        }

        /* internal  */updateFieldsByPage(): void
        {
            var loc1=(this._pageSelecter.currentPage - 1) * this.PageSize;
            var loc2=Math.min(loc1 + this.PageSize, this._fields.length);
            var loc3=new Array<any>();
            var loc4=loc1;
            while (loc4 < loc2) 
            {
                loc3.push(this._fields[loc4]);
                ++loc4;
            }
            this._tileList.dataProvider = new DataProvider(loc3);
            this._tileList.drawNow();
            return;
        }

        public static get instance(): WrestleEnterWindow
        {
            if (!WrestleEnterWindow._instance) 
            {
                WrestleEnterWindow._instance = new WrestleEnterWindow();
            }
            return WrestleEnterWindow._instance;
        }

        public static hasInstance(): Boolean
        {
            return !(WrestleEnterWindow._instance == null);
        }

        /* internal */ /* var */_tileList: GTileList;

        /* internal */ /* var */_pageSelecter: PageSelecter;

        /* internal */ /* var */_tfDesc: Object /* flash.text.TextField */;

        /* internal */ /* var */_fields: Array<any>;

        /* internal */ /* var */PageSize: int=10;

        /* internal */ static /* var */_instance: WrestleEnterWindow;
    }
